package cn.whut.glab.web;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

import cn.whut.glab.domain.BD_Permission;
import cn.whut.glab.domain.TreeNode;
import cn.whut.glab.service.PermissionService;

/**
 * Servlet implementation class GetPerListServlet
 */
public class GetPerListServlet extends HttpServlet {

	PermissionService service = new PermissionService();

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setHeader("Content-type", "text/html;charset=UTF-8");  
		try {
			List<TreeNode> list = service.getAllPermission();
			Gson gson=new Gson();
			String str=gson.toJson(list);
			response.getWriter().write(str);
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
